package club.jdiy.utils.reflex;


import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * 这是一个反射获取泛型类真实类的有用的方法．
 *
 * @author ziquee(子秋) QQ号:39886616 主页: http://www.jdiy.club
 * @version 20200517
 */
public class RefParmzType {

/*
    public static void main(String[] args) throws Exception {
        Field f=   RefParmzType.class.getDeclaredField("app");
        Type fc = f.getGenericType();

        if (fc instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType) fc;

            Class genericClazz = (Class) pt.getActualTypeArguments()[0];
            System.out.println(f.getName() + "_____" + genericClazz);
        }
        List<String> s = (List<String>)xxx();

    }*/

    private Class<?> getParamzType(Field f) {
        Type fc = f.getGenericType();
        if (fc instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType) fc;
            return (Class<?>) pt.getActualTypeArguments()[0];
        }
        return f.getType();
    }

}
